package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class<?> cls = Class.forName("reflect.Person");
        Method method = cls.getMethod("say", String.class, int.class);

        String name = method.getName();
        System.out.println("方法名:"+name);
        System.out.println(method.getReturnType());
        System.out.println(method.getParameterCount());

        Class<?>[] p = method.getParameterTypes();
        for (Class<?> pt : p) {
            System.out.println(pt);
        }

        int modifiers = method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("是一个public方法");
                break;
            case Modifier.PRIVATE:
                System.out.println("是一个private方法");
                break;
            case Modifier.PROTECTED:
                System.out.println("是一个protected方法");
                break;
            default:
                System.out.println("是一个default方法");

        }
    }
}
